﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WWWSiteHelper
{
    class TypeConverter
    {
        public static string getFilter(AbstractFile.FileType type)
        {
            switch (type)
            {
                case AbstractFile.FileType.Css:
                    return "CSS (*.css)|*.css";
                case AbstractFile.FileType.Html5:
                    return "HTML (*.html)|*.html";
                case AbstractFile.FileType.JavaScript:
                    return "JavaScript (*.js)|*.js";
                case AbstractFile.FileType.Php:
                    return "PHP (*.php)|*.php";
            }
            return null;
        }

        public static string getString(AbstractFile.FileType type)
        {
            switch (type)
            {
                case AbstractFile.FileType.Css:
                    return "css";
                case AbstractFile.FileType.Html5:
                    return "html";
                case AbstractFile.FileType.JavaScript:
                    return "js";
                case AbstractFile.FileType.Php:
                    return "php";
            }
            return null;
        }

        public static AbstractFile.FileType getType(string path)
        {
            string ext = path.Substring(path.LastIndexOf('.'));
            if (ext == ".css")
                return AbstractFile.FileType.Css;
            if (ext == ".js")
                return AbstractFile.FileType.JavaScript;
            if (ext == ".php" || ext == ".php5")
                return AbstractFile.FileType.Php;
            return AbstractFile.FileType.Html5;
        }
    }
}
